package com.sc.userspringboot.RedisController;


import com.sc.userspringboot.pojo.Users;
import com.sc.userspringboot.service.IUsersService;
import com.sc.userspringboot.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/redis")
public class RedisController {
    @Autowired
    RedisUtils redisUtils;
    @Autowired
    IUsersService usersService;

    @RequestMapping("/set/{k}/{v}")
    Object set(@PathVariable String k, @PathVariable String v) {
        return redisUtils.set(k, v);
    }

    @RequestMapping("/get/{k}")
    Object get(@PathVariable String k) {
        return redisUtils.get(k);
    }
    @RequestMapping("set2")
    Object set2(String k){
        Users users = usersService.getById(1);
        return redisUtils.set(k, users);
    }
    @RequestMapping("lset/{k}/{m}")
    Object lset(@PathVariable String k, @PathVariable String m) {
        return redisUtils.lSet(k, m);
    }
    @RequestMapping("lget/{k}")
    Object lget(@PathVariable String k) {
        return redisUtils.lGet(k, 0, -1);
    }
}
